package com.biodiv.client.loadBalan;

import com.biodiv.client.loadBalan.strategy.*;


/**
 * @Author: tianquan
 * @date: 2024-11-04  12:11
 * @Description: 负载均衡工厂
 */
public class LoadBalancerFactory {

    public static LoadBalancer getLoadBalancer(LoadBalancerEnum type) {
        if (LoadBalancerEnum.Random == type) {
            return new RandomLoadBalancer();
        }
        if (LoadBalancerEnum.RoundRobin == type) {
            return new RoundRobinLoadBalancer();
        }
        if (LoadBalancerEnum.WeightedRoundRobin == type) {
            return new WeightedRoundRobinLoadBalancer();
        }
        throw new RuntimeException("不支持的负载均衡类型");
    }

}
